using System;
using System.Runtime.CompilerServices;
using System.Xml;
namespace Microsoft.Phone.Controls.Maps.Core
{
	internal class MapConfigurationFromFile : MapConfigurationProvider
	{
		private readonly XmlReader config;
		public override event EventHandler<MapConfigurationLoadedEventArgs> Loaded
		{
			[MethodImpl(32)]
			add
			{
				this.Loaded = (EventHandler<MapConfigurationLoadedEventArgs>)Delegate.Combine(this.Loaded, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.Loaded = (EventHandler<MapConfigurationLoadedEventArgs>)Delegate.Remove(this.Loaded, value);
			}
		}
		public MapConfigurationFromFile(XmlReader config)
		{
			this.config = config;
		}
		public override void LoadConfiguration()
		{
			try
			{
				base.Sections = MapConfigurationProvider.ParseConfiguration(this.config);
				if (this.Loaded != null)
				{
					this.Loaded.Invoke(this, new MapConfigurationLoadedEventArgs(null));
				}
			}
			catch (Exception error)
			{
				if (this.Loaded != null)
				{
					this.Loaded.Invoke(this, new MapConfigurationLoadedEventArgs(error));
				}
			}
		}
		public override void GetConfigurationSection(string version, string sectionName, string culture, MapConfigurationCallback callback, object userState)
		{
			if (callback != null)
			{
				callback(base.GetSection(version, sectionName, culture), userState);
			}
		}
	}
}
